Imports System.Windows.Forms

Public Class DlgChooseFile
    Public fileList As System.Collections.Specialized.StringCollection
    Public SelectedFile As String

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        If lstFiles.SelectedIndex > -1 Then
            SelectedFile = Convert.ToString(lstFiles.SelectedItem)
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.Close()
        End If
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub DlgChooseFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If fileList IsNot Nothing Then
            For Each tmpfile As String In fileList
                lstFiles.Items.Add(tmpfile)
            Next
        End If
    End Sub

    Private Sub lstFiles_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstFiles.DoubleClick
        OK_Button_Click(Me, Nothing)
    End Sub

End Class
